home *** CD-ROM | disk | FTP | other *** search
/ Aminet 33 / Aminet 33 - October 1999.iso / Aminet / util / cli / cliutils_mra.lha / Sources / RequestChoice / RequestChoice2.a < prev   
Encoding:
Text File  |  1998-09-02  |  4.2 KB  |  199 lines

  1. ;
  2. ; $VER: RequestChoice.a v36.1 written by Mauro Panigada
  3. ;
  4. ; Started:  1998.07.16
  5. ; Finished: 1998.07.16
  6. ;
  7. ; Requirements: OS2.0 (#36), 020+ (this is 020 version, only for odd addrs, I believe!)
  8. ; Purpose: replace RequestChoice command, so long to me.
  9. ; Note: it is PURE.
  10. ;
  11. ; Usage: TITLE/A,BODY/A,GADGETS,PUBSCREEN/K
  12. ;
  13. ; TITLE: the title of the window
  14. ; BODY: the body text you will read
  15. ; GADGETS: the gadgets: retry|resume or "go on|go down|go up"
  16. ; PUBSCREEN: the name of a pubscreen, if you want
  17. ;
  18. ; Note: * if the given PUBSCREEN does not exist, it open the requester on the default
  19. ;   public screen (ie often Workbench), this behavior is different from the original
  20. ;   RequestChoice (which says "not enough memory available"!)
  21. ; * this RequestChoice, leaves the pressed button also in d0, so you could check it
  22. ;   in startup-sequence as if it is an error (or a condition code returned by a prg)
  23. ; * the way you pass the gadgets in this RequestChoice is different: not as multiple
  24. ;   string but as a sequence of string separated by | (so EasyRequest requires!), and
  25. ;   you can forget it: the default gadgets are "Yes|No" for two ways answer (are you
  26. ;   an Amiga's friend? Yes I am; no I am not.)
  27. ; * return code for a real error (not for gadget) is 30 (put failat 25, for example...
  28. ;   I think it is rare you have more than 24 gadgets!)
  29. ;
  30.  
  31.  
  32.         incdir    "dh0:progr/assem/include/"
  33.         include    "exec/types.i"
  34.         include    "exec/memory.i"
  35.         include    "exec/libraries.i"
  36.         include    "exec/exec_lib.i"
  37.         include    "dos/dos.i"
  38.         include    "dos/dosextens.i"
  39.         include    "dos/dos_lib.i"
  40.         include    "intuition/intuition.i"
  41.         include    "intuition/intuition_lib.i"
  42.  
  43. LIBVERSION    EQU    36
  44.  
  45. CALL        MACRO
  46.         jsr    _LVO\1(a6)
  47.         ENDM
  48.  
  49.     STRUCTURE internal,0
  50.         LONG    execbase
  51.         LONG    oldstack
  52.  
  53.         LABEL    array
  54.         LONG    title
  55.         LONG    body
  56.         LONG    gadgets
  57.         LONG    pubscreen
  58.  
  59.         STRUCT    ERS,EasyStruct_SIZEOF
  60.  
  61.         LONG    returncode
  62.         LONG    result2
  63.  
  64.         LABEL    s_size        ; word aligned, please
  65.  
  66.  
  67.     SECTION    codice,CODE
  68.  
  69.         opt    p=68020            ; but in old style!
  70.  
  71.         bra.s    start
  72.  
  73.         dc.b    "$VER: RequestChoice 36.1 [020+] (1998.07.16) "
  74.         dc.b    "by Mauro Panigada",13,10
  75.         dc.b    0
  76.         even
  77.  
  78. start        move.l    sp,a0
  79.         move.w    #(s_size/2)-1,d0
  80. lap        clr.w    -(sp)
  81.         dbf    d0,lap
  82.         move.l    sp,a5
  83.         move.l    a0,oldstack(a5)
  84.  
  85.         move.b    #20,returncode+3(a5)
  86.         movea.l    4.w,a6
  87.         move.l    a6,(a5)
  88.         lea    dosname(pc),a1
  89.         moveq    #LIBVERSION,d0
  90.         CALL    OpenLibrary
  91.         move.l    d0,d7            ; d7=dos
  92.         beq    exit
  93.         lea    intname(pc),a1
  94.         moveq    #LIBVERSION,d0
  95.         CALL    OpenLibrary
  96.         move.l    d0,d6            ; d6=intuition
  97.         beq    exit
  98.         move.l    d7,a6
  99.  
  100.         lea    template(pc),a0
  101.         move.l    a0,d1
  102.         move.l    a5,d2
  103.         addq.l    #array,d2
  104.         moveq    #0,d3
  105.         CALL    ReadArgs
  106.         move.l    d0,d5            ; d5=readargs
  107.         beq    argerror
  108.  
  109. main        lea    ERS(a5),a1
  110.         move.l    #EasyStruct_SIZEOF,(a1)
  111.         move.l    body(a5),es_TextFormat(a1)
  112.         lea    stdgad(pc),a0
  113.         move.l    a0,es_GadgetFormat(a1)
  114.         tst.l    gadgets(a5)
  115.         beq.s    okarg0
  116.         move.l    gadgets(a5),es_GadgetFormat(a1)
  117. okarg0        move.l    title(a5),es_Title(a1)
  118.         move.l    a1,-(sp)
  119.  
  120.         moveq    #0,d4
  121.         move.l    d6,a6
  122.         suba.l    a0,a0
  123.         tst.l    pubscreen(a5)
  124.         beq.s    nops
  125.  
  126.         move.l    pubscreen(a5),a0
  127.         CALL    LockPubScreen
  128.         move.l    d0,a0
  129.         move.l    d0,d4            ;d4=screenlock
  130.         beq.s    nops
  131.         move.l    sc_FirstWindow(a0),a0
  132.  
  133. nops        move.l    (sp)+,a1
  134.         suba.l    a2,a2
  135.         suba.l    a3,a2
  136.         CALL    EasyRequestArgs
  137.         move.l    d0,-(sp)
  138.         move.l    d0,d3
  139.         tst.l    d4
  140.         beq.s    nunl
  141.         move.l    d4,a0
  142.         CALL    UnlockPubScreen
  143. nunl        move.l    d7,a6
  144.         lea    formatstr(pc),a0
  145.         move.l    a0,d1
  146.         move.l    sp,d2
  147.         CALL    VPrintf
  148.         addq.l    #4,sp
  149.         clr.l    returncode(a5)
  150.         move.l    d3,d1
  151.         CALL    SetIoErr
  152.  
  153. exit0        move.l    d5,d1
  154.         beq.s    exit
  155.         CALL    FreeArgs
  156.  
  157. exit        move.l    d6,a1
  158.         movea.l    4.w,a6
  159.         CALL    CloseLibrary
  160.         move.l    d7,a1
  161.         CALL    CloseLibrary
  162.  
  163.         move.l    returncode(a5),d0
  164.         move.l    oldstack(a5),sp
  165.         rts
  166.  
  167. doserror
  168. argerror    CALL    IoErr
  169.         move.l    d0,d1
  170.         moveq    #0,d2
  171.         CALL    PrintFault
  172.         move.b    #20,returncode+3(a5)
  173.         bra.s    exit0
  174.  
  175. *convert        movem.l    a0/a6,-(sp)
  176. *        movea.l    4.w,a6
  177. *        lea    formatstr(pc),a0
  178. *        lea    stream(pc),a1
  179. *        lea    proc(pc),a2
  180. *        lea    cbuf(pc),a3
  181. *        CALL    RawDoFmt
  182. *        movem.l    (sp)+,a0/a6
  183. *        rts
  184. *proc        move.b    d0,(a3)+
  185. *        rts
  186.  
  187. ;=========================================================================
  188. dosname        dc.b    "dos.library",0
  189. intname        dc.b    "intuition.library",0
  190. *ers        dc.l    EasyStruct_SIZEOF
  191. *        dc.l    0
  192. *        dc.l    0,0,0
  193. template    dc.b    "TITLE/A,BODY/A,GADGETS,PUBSCREEN/K",0
  194. formatstr    dc.b    "%ld"
  195. accapo        dc.b    10,0
  196. stdgad        dc.b    "Yes|No",0
  197.  
  198.  
  199.         END